import * as types from './types'

export default {
    increment: ({ commit }) => {
        commit(types.INCREMENT)
    },
    decrement: ({ commit }) => {
        commit(types.DECREMENT)
    },
    timeIncrement: ({ commit, state }) => {
        new Promise((resolve) => {
            setTimeout(() => {
                commit(types.INCREMENT)
            }, 1000)
        })
    },
    oddIncrement: ({ commit, state }) => {
        if (!(state.count % 2 == 0)) {
            commit(types.INCREMENT)
        }
    }
}